﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace T15OOP2
{
    abstract class Product
    {
        protected string name; //产品名
        protected decimal price; //价格

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public decimal Price
        {
            get { return price; }
            set { price = value; }
        }

        //this("") 表示调用带参的构造函数
        public Product() : this("")
        {
            Debug.WriteLine("-=调用Product无参构造方法=-");
        }

        public Product(string name)
        {
            this.name = name;
            Debug.WriteLine("-=调用Product带参构造方法=-");
        }

        public virtual void Show()
        {
            Console.WriteLine("产品名称:{0}", name);
            Console.WriteLine("产品价格:{0}", price);
        }

        /// <summary>
        /// 显示产品详细信息
        /// </summary>
        public abstract void ShowDetail();


        ~Product()
        {
            Debug.WriteLine("-=调用Product析构方法=-");
        }
    }
}